Getting Started with CreateJS by 2014

Getting Started with CreateJS by 2014

Author:2014
Language: eng
Format: mobi
Publisher: Packt Publishing


The following is the source code of this example:

function init() { var canvas = document.getElementById("canvas"); var stage = new createjs.Stage(canvas); var image = new Image(); image.src = "easeljs.png"; //wait to load the image image.onload = function(evt) { var bitmap = new createjs.Bitmap(evt.target); var width = bitmap.image.width; var height = bitmap.image.height; //clone the existing bitmap to use as reflection var reflectBitmap = bitmap.clone(); reflectBitmap.regY = height; reflectBitmap.rotation = 180; //to add a padding from the main bitmap reflectBitmap.y = height + 2; reflectBitmap.scaleX = -1; var maskShape = new createjs.Shape(); var graphics = maskShape.graphics; //add reflection effect graphics.beginLinearGradientFill(["rgba(255, 255, 255, 0)", "rgba(255, 255, 255, 0.6)"], [0.5, 1], 0, 10, 0, height); graphics.drawRect(0, 0, width, height); graphics.endFill(); maskShape.cache(0, 0, width, height); reflectBitmap.filters = [new createjs.AlphaMaskFilter(maskShape.cacheCanvas)]; reflectBitmap.cache(0, 0, width, height); //add both pictures stage.addChild(bitmap); stage.addChild(reflectBitmap); stage.update(); } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.